/**
 * 
 *  @project Air Traff Monitor
 * 
 *  @author M.Emre ATASEVER <m.emre.atas@gmail.com>
 *  @author M.Burak ALKAN <mburakalkan@gmail.com>
 *  @author H.Burak KARAMIK <bkaramik@gmail.com>
 *
 *	`Air Traffic Monitor' is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef  ALERTMODEL_INC
#define  ALERTMODEL_INC

#include <QAbstractItemModel>
#include <QVariant>
#include <QDateTime>

#include "kisock.h"
#include "kismodel.h"

struct AlertRootItem;

class AlertItem
{
public:
	AlertItem(alertInfo *data,AlertRootItem *parent);
	~AlertItem();

	int row();
	QVariant data(int column);
	void setData(alertInfo *data);

	AlertRootItem *parent();

	QDateTime time;
private:
	AlertRootItem *root;
	QList<QPair<QVariant,int> > itemData;

};

struct AlertRootItem
{
	public:
		QList<AlertItem*> items;
};

class AlertModel : public KismetDataModel<AlertRootItem, AlertItem>
{
	Q_OBJECT
public:
		AlertModel(QKismetSocket *sock, QObject *parent = 0);

		QVariant data(const QModelIndex &index, int role) const;
		QVariant headerData(int section, Qt::Orientation orientation,int role = Qt::DisplayRole) const;

		QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
		QModelIndex parent(const QModelIndex &index) const;
		int columnCount(const QModelIndex &parent = QModelIndex()) const;

public slots:
		void alInfo(alertInfo info);

private:
		AlertItem* findItem(int time);
		
};
#endif
